<?php

error_reporting(E_ALL);

/**
 * ECommerce - class.ControladorProveedor.php
 *
 * $Id$
 *
 * This file is part of ECommerce.
 *
 * Automatically generated on 17.11.2011, 16:45:29 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/* user defined includes */
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B0-includes begin
require_once('class.VistaProveedor.php');
require_once('class.ModeloProveedor.php');
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B0-includes end

/* user defined constants */
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B0-constants begin
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B0-constants end

/**
 * Short description of class ControladorProveedor
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ControladorProveedor
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    /**
     * Short description of attribute miVistaProveedor
     *
     * @access public
     * @var VistaProveedor
     */
    public $miVistaProveedor = null;

    /**
     * Short description of attribute miModeloProveedor
     *
     * @access public
     * @var ModeloProveedor
     */
    public $miModeloProveedor = null;

    // --- OPERATIONS ---

    /**
     * Short description of method Lista
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function Lista()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B7 begin
        $datos=$this->miModeloProveedor->getAllRows();		
		$this->miVistaProveedor->Lista($datos);
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B7 end
    }
    
    /**
     * Short description of method Alta
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function Alta()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B9 begin
          if (@$_REQUEST[Aceptar]) {
				$this->miModeloProveedor->insertRow($_REQUEST);
				$this->Lista();
				}
			else
				$this->miVistaProveedor->Alta();
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013B9 end
    }

    /**
     * Short description of method Editar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function Editar()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013BB begin
        if (@$_REQUEST[Aceptar]) {								// Boton Aceptar
				$this->miModeloProveedor->updateRow(@$_REQUEST);		// Graba en el modelo
				$this->Lista();									// Muestra la lista
			}
			else {	
					$datos = $this->miModeloProveedor->searchById(@$_REQUEST[id]);
					$this->miVistaProveedor->Edicion($datos);
			}	
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013BB end
    }

    /**
     * Short description of method Borrar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function Borrar()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013BD begin
         if (@$_REQUEST[Aceptar]) {
				$this->miModeloProveedor->deleteRow(@$_REQUEST[id]);
				$this->Lista();
			}
			else {	
				$datos = $this->miModeloProveedor->searchById(@$_REQUEST[id]);
				$this->miVistaProveedor->borrar($datos);
			}	
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013BD end
    }

    /**
     * Short description of method ControladorProv
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function ControladorProveedor()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013BF begin
        $this->miModeloProveedor = new ModeloProveedor();		
		$this->miVistaProveedor = new VistaProveedor();		
		//var_dump($_REQUEST);
		// VISTA 
		if(@$_REQUEST["controlador"]=="listaProveedor" || @$_REQUEST[Cancelar]) 		// Boton generico cancelar
		{
			$this->Lista();
		}
		else 
		{
			if(@$_REQUEST["controlador"]=="buscarProveedor") 	
				$this->Buscar();
			if(@$_REQUEST["controlador"]=="nuevoProveedor")
				$this->Alta();			
			if(@$_REQUEST["controlador"]=="editarProveedor")
				$this->Editar();
			if(@$_REQUEST["controlador"]=="borrarProveedor") 
				$this->Borrar();
		}
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013BF end
    }

    /**
     * Short description of method Buscar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function Buscar()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013C1 begin
        $datos=$this->miModeloProveedor->getRowsByNombre($_REQUEST["nombre"]);		
		$this->miVistaProveedor->Lista($datos);
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013C1 end
    }

} /* end of class ControladorProveedor */

?>